<template>
    <div>
        <a-button :type="type" @click="handClick">{{ typeObj[dataVal] }}</a-button>
    </div>
</template>
<script>
export default {
    name: 'ButtonChang',
    props: {
        menuId: {
            type: [String, Number],
            default: '977',
        },
        otherData: {
            type: Object,
            default: () => { }
        },
        onCallBack: {
            type: Function,
            default: () => { }
        },
        dataIndex: {
            type: String,
        },
        dataVal: {
            type: [String, Number],
        }
    },
    data() {
        return {
            type: '',
            typeObj: { '1': '巡检预警', '2': '送检预警', '3': '报废预警' }
        }
    },
    methods: {
        handClick() {
            if (this.otherData[this.dataIndex] == this.dataVal) {
                this.onCallBack('0', this.dataIndex);
            } else {
                this.onCallBack(this.dataVal, this.dataIndex);
            }
        }
    },
    mounted() {
    },
    watch: {
        otherData: {
            handler(nVal, oVal) {
                if (nVal[this.dataIndex] == this.dataVal) {
                    this.type = 'primary'
                } else {
                    this.type = ''
                }
            }
        }
    }
}
</script>
<style lang="less" scoped></style>